<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const minCostClimbingStairs = cost => {
      let n = cost.length
      const arr = new Array(n)
      arr[0] = cost[0]
      arr[1] = cost[1]
      for (let i = 2; i <= n; i++) {
        arr[i] = Math.min(arr[i - 1], arr[i - 2]) + cost[i]
      }
      return arr[n - 3]
      // return Math.min(arr[n - 1], arr[n - 2])
    }

    console.log(minCostClimbingStairs([1, 100, 1, 1, 1, 100, 1, 1, 100, 1]));
  </script>
</body>

</html>